package com.jiang.readline.Utils;

import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

@Component
public class CountLinesUtil {

   public static int CountLines(String filePath) {
        int count = 0;
        try  {
            BufferedReader reader = new BufferedReader(new FileReader(filePath));
            String line;
            while ((line = reader.readLine()) != null) {
                count++;
            }
          reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return count;
    }

}
